<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改知识安排')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-arrange-edit" th:object="${courseArrange}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">选择知识</label>
            <div class="col-sm-8">
                <select id="course" class="form-control m-b">
                    <option th:each="course:${courses}" th:value="${course.id}"
                            th:text="${course.name}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">知识时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="courseDate"
                           th:value="${#dates.format(courseArrange.courseDate, 'yyyy-MM-dd')}"
                           class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">知识节数：</label>
            <div class="col-sm-8">
                <input name="timeSort" th:field="*{timeSort}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "demo/arrange";
    $("#form-arrange-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-arrange-edit").serializeArray();
            var type = $.form.selectSelects("course");
            data.push({"name": "courseId", "value": type});
            $.operate.save(prefix + "/edit", data);
        }
    }

    $(function () {
        $('#course').select2({
            placeholder: "请选择图书类型",
            allowClear: true
        });
    })

    $("input[name='courseDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>